package com.example.nypindoormap;



import com.example.nypindoormap.R;





import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.nypindoormap.MainActivity;

public class MapActivity extends FragmentActivity { 
	


	
	private ImageView image1;
		
	/** declare Variables */
	
	LocationManager locationManager;
	LocationListener gpsaltLocationListener;
	LocationListener wifiLocationListener;
	LocationListener locationListener;
	
	private static final String TAG = "MapActivity";
	
	
	double gpsalt;	
	EditText level4;
	EditText level3;
	EditText level2;
	EditText level1;
	private boolean appear;
	

	protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
      
        ImageView iv = (ImageView) findViewById(R.id.image1);  
        iv.setOnTouchListener(new Touch());   
        
       level4=(EditText)findViewById(R.id.edfour);
       
 

       displayView();      
       
		  /*ImageView image = (ImageView) findViewById(R.id.image1);
          
          Bitmap loadedBitmap = BitmapFactory.decodeResource(getBaseContext().getResources(), R.drawable.floor_planfinal);//put your imagename here
          Bitmap bitmap = loadedBitmap.copy(Bitmap.Config.ARGB_8888, true);
         
           Canvas canvas = new Canvas(bitmap);
           Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
           paint.setColor(Color.RED);//change your color here
           canvas.drawCircle(50, 50, 10, paint);//enter your coordinates here
           image.setImageBitmap(bitmap);*/
	}
	

	public void displayView()
    {
			
		    Bundle o= getIntent().getExtras();
		    double gpsalt=o.getDouble("key");
		    ImageView imgview = (ImageView) findViewById(R.id.image1);
		    //String a = Double.toString(gpsalt);
			//level4.setText(a);
			if(gpsalt> 54.0 && gpsalt<80.0)
			{
			
				level4.setText("You are in level 4");
				
				
				
				 Bitmap loadedBitmap = BitmapFactory.decodeResource(getBaseContext().getResources(), R.drawable.floor_planfinal);//put your imagename here
		          Bitmap bitmap = loadedBitmap.copy(Bitmap.Config.ARGB_8888, true);
		         
		           Canvas canvas = new Canvas(bitmap);
		           Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		           paint.setColor(Color.RED);//change your color here
		           canvas.drawCircle(0, 0, 8, paint);
		           canvas.drawCircle(100, 50, 8, paint);//enter your coordinates here
		           canvas.drawCircle(130, 50, 8, paint);//enter your coordinates here
		           //canvas.drawLine(200, 60, 0, 50, paint);
		           imgview.setImageBitmap(bitmap);
				//imgview.setImageResource( R.drawable.floor_planfinal );
						
			}
			
			else if(gpsalt> 40.0 && gpsalt <53.9)
			{
				
				level4.setText("You are in level 3");
				
				 Bitmap loadedBitmap = BitmapFactory.decodeResource(getBaseContext().getResources(), R.drawable.level_three);//put your imagename here
		          Bitmap bitmap = loadedBitmap.copy(Bitmap.Config.ARGB_8888, true);
		         
		           Canvas canvas = new Canvas(bitmap);
		           Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		           paint.setColor(Color.BLUE);//change your color here
		           canvas.drawCircle(100, 50, 10, paint);//enter your coordinates here
		           canvas.drawCircle(130, 50, 10, paint);//enter your coordinates here
		           canvas.drawLine(450, 15, 50, 30, paint);
		           imgview.setImageBitmap(bitmap);
				
				
				//imgview.setImageResource( R.drawable.level_three );
				
			}
			
			else if(gpsalt>30.0 && gpsalt< 54.9)
			{
			   level4.setText("You are in level 2");
			}
			else{
				level4.setText("You are in level 1");
			}
    }
}
			
			
			
			
			
			
	
	
  
	



